from keras.layers import Input, Dense, concatenate, RepeatVector, Lambda
from keras.models import Model
from keras.optimizers import adam_v2
import keras.backend as K
import numpy as np
import keras.losses as KLoss
import matplotlib.pyplot as plt

plt.rcParams['font.sans-serif'] = ['SimHei']
plt.rcParams['axes.unicode_minus'] = False
# predict = [0.2, 0.2, 0.28, 0.36, 0.32, 0.3, 0.4, 0.36, 0.44, 0.44, 0.4, 0.48, 0.48, 0.56, 0.52, 0.56, 0.56, 0.64, 0.6, 0.64, 0.64, 0.64, 0.68, 0.68, 0.64, 0.68]  #  效果最好的数据
predict = [0.1, 0.1, 0.2, 0.24, 0.24, 0.2, 0.3, 0.3, 0.32, 0.35, 0.35, 0.4, 0.4, 0.45, 0.4, 0.45, 0.45, 0.48, 0.48, 0.48, 0.49, 0.50, 0.52, 0.53, 0.53, 0.54]  #  效果最好的数据
dist2 = [0.24, 0.24, 0.28, 0.28, 0.28, 0.28, 0.32, 0.32, 0.36, 0.36, 0.4, 0.4, 0.4, 0.44, 0.44, 0.44, 0.44, 0.48, 0.48, 0.48, 0.48, 0.52, 0.52, 0.52, 0.52, 0.52]
if __name__ == '__main__':
    # predict = [0.08, 0.12, 0.04, 0.12, 0.12, 0.12, 0.16, 0.16, 0.16, 0.16, 0.16, 0.16, 0.12, 0.2, 0.24, 0.24, 0.28, 0.36, 0.32, 0.32, 0.32, 0.36, 0.36, 0.44, 0.44, 0.52]
    # plt.plot(predict, label='通过软标签训练的模型')
    plt.plot(predict, label='通过软标签训练的模型')
    plt.plot(dist2, label='基于显式信息的推理方法')
    plt.xlabel('Move')
    plt.ylabel('probability evaluate accuracy%')
    plt.title('学习率为0.008的测试结果')
    plt.legend(prop={'family': 'SimHei', 'size': 15})
    plt.show()


'''totSum=25

dist1 = Input(shape=(12,),name='dist1')
dist2 = Input(shape=(12,),name='dist2')
sum = Input(shape=(1,),name='sum')
allInput = concatenate([dist1, dist2, sum])
layer1 = Dense(20, activation='relu')(allInput)
layer1 = Dense(16, activation='relu')(layer1)
'''
'''k = Dense(1, activation='relu')(layer1)
dist2 = mulFirst()([k,dist2])

allInput = concatenate([dist1, dist2, sum])
layer2 = Dense(32, activation='relu')(allInput)
layer2 = Dense(12, activation='relu')(layer2)'''
'''
layer2 = Dense(12, activation='relu')(layer1)
layer2 = Lambda(lambda x: x * totSum / K.sum(x))(layer2)
output = Lambda(lambda x: K.abs(x))(layer2)
trainOutput = RepeatVector(2)(output)

def loss(y_true, y_pred):
    return K.min(KLoss.mean_squared_error(y_true,y_pred))


model = Model(inputs=[dist1, dist2, sum], outputs=trainOutput)
model.compile(loss=loss, optimizer=adam_v2.Adam(lr=0.01))
print(model.summary())


t2 = np.zeros((10,12))
t1 = np.zeros((10,12))
replaySum=np.full((10,),25)
x=[t1,t2,replaySum]

y=np.zeros((10,2,12))

model.fit(x,y)
print(model.predict(x))'''